home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / rTutors / Read.Me
Encoding:
Text File  |  1990-08-21  |  8.8 KB  |  160 lines  |  [TEXT/pdos]

  1. The folders at this level contain the stages that currently exist for a
  2. tutorial on using resources.  The parts are numbered in order, but tend to
  3. skip around a little (to better show the magnitude of changes from one part
  4. to another).  The source code does not necessarily follow all of the
  5. conventions that the official DTS sample source code does.  If you're
  6. looking for a good programming style to follow, use their code.  If you're
  7. just trying to figure out what it all means, then this stage by stage
  8. approach should be very useful.
  9.  
  10. This version was written using APW C and Rez.  The APW C files can be
  11. compiled without modifications using MPW IIGS C, but the Rez sources will
  12. need one minor change in order to work with RezIIGS.  You'll have to
  13. change the "#include types.rez" to "#include TypesIIGS.r" (otherwise,
  14. RezIIGS won't be able to find the standard resource types).
  15.  
  16. If there's an overwhelming demand for this approach in another language,
  17. then perhaps I can be persuaded to change languages (or make clones of
  18. this available in other languages).  Send email requests to
  19. "Bit.Bucket"...  (the real info on where to send requests is at the end
  20. of this file).
  21.  
  22. The tutorial is set up to make the change from one stage to the next as
  23. small as possible (without being meaningless).  The first part simply
  24. shows how to startup and shutdown the tools using a tool startup list
  25. kept in a resource.  Once the tools are started up, the application calls
  26. SysBeep three times (resulting in three beeps), shuts down the tools,
  27. and quits.
  28.  
  29. Part 2 adds a menu bar full of menus after the tools are started and before
  30. the triple beeps.  The Apple menu (with desk accessories inserted), the
  31. File menu, and the Edit menu are all installed.  These menus closely follow
  32. the Human Interface Guidelines with the exception that the items relating
  33. to printing are NOT in the menus.
  34.  
  35. Part 2.5 is simply part 2 with an event loop instead of three beeps.  This
  36. allows you to explore a "minimum" application that uses resources.  Desk
  37. accessories are functional and can use the Edit menu.
  38.  
  39. Part 3 opens a window (using a template in a resource, naturally) that has
  40. a couple of controls in it.  The controls are kept in resources and are
  41. active - the simple button can be clicked on and will highlight (notice
  42. that there is NO source code driving this???  TaskMaster does the dirty
  43. work for us).  The text edit field works also - you can cut/copy/paste
  44. to and from it, words will automatically wrap to stay within it, and the
  45. scroll back becomes active if enough text is added to fill the visible
  46. region.  Again, notice that there is nothing in our application driving
  47. this - TaskMaster is doing it for us.  The window can be moved around the
  48. desktop, but can't be closed.  
  49.  
  50. The controls are added to the window AFTER it has been created using
  51. NewControl2.  This was done in accordance with IIGS Tech Note #82
  52. (Controlling the Control Manager).  Tech Note #82 warns us that NewWindow2
  53. doesn't set the Graf Port correctly before automatically installing the
  54. controls in the window.  We work around this by not letting NewWindow2
  55. automatically install our controls - we install them with a call to
  56. NewControl2 _AFTER_ we set the current GrafPort to the newly created one
  57. (created by NewWindow2).  We stop the automatic installation by simply
  58. putting a NULL in the second to last field of the rWindParam1 resource for
  59. our window (see the rTutor.Rez source for details).  If you're lost by all
  60. of this, then get IIGS Tech Note #82 and read it.
  61.  
  62. Since several new routines had to be added to the source code to implement
  63. the event loop and to implement the window, I split the changes into two
  64. smaller parts.  That's why there is a part 2.5 and a part 3.  Part 2.5 is
  65. half way (sort of) between part 2 and part 3.  This should make it easier
  66. to see what had to be added to the application, and to the resource fork,
  67. to move from one part to the next.
  68.  
  69. Part 3.2 changes the About box from a simple beep (added in part 2.5) to
  70. an Alert Window.  The Alert Window is a custom size and shows how to imbed
  71. formatting characters in the text.  The Alert Window itself is a custom
  72. size - this was done to further demonstrate the flexibility of the
  73. AlertWindow tool call.  I opted not to include an icon in the Alert Window
  74. because that causes the text to be pushed off of true center.  I could have
  75. compensated for that by padding the text with trailing white space, but I
  76. wanted to keep things simple for now.  I'll leave the icon and re-centering
  77. as an exercise for the reader...  <grin>
  78.  
  79. Part 3.2's Rez source has been split into two files.  The first file is
  80. simply the stuff from Part 3 and the new file is the Alert Window's
  81. definition.  I split it into two parts to highlight Rez's ability to append
  82. new resources onto an existing file and to show Rez's ability to include
  83. already compiled resources.  Both of these techniques SHOULD be part of
  84. your development cycle.  Why?  Because there's no point in recompiling
  85. resources that haven't changed!  By splitting them into seperate files, you
  86. can compile ONLY the parts that have changed (making your compile times
  87. shorter).  The ability to "include" pre-compiled resources provides you with
  88. an easy way to implement standard resource "libraries" - i.e.:  already
  89. compiled resource forks with the resources you use in all applications.
  90.  
  91. Part 3.2 also comes with a second MAKE file.  The second one assumes you've
  92. already run the first one and won't work if you haven't.  The point of the
  93. second one is to further highlight the use of "include" and append (via
  94. the "-a" flag on the command line).  It also shows how to define, on the
  95. command line, constants used within the Rez files themselves.  Being able to
  96. set constants on the command line allows you MUCH greater control over
  97. conditional compiles.  To see both versions of the second MAKE file, you
  98. have to read the information it sends to the screen (or print it) and make
  99. a couple of MINOR edits to the file (to comment out the first method and 
  100. uncomment the second one).
  101.  
  102. Part 3.3 shows how to use icons and cursors that are stored as resources.  The current template in Types.Rez (and TypesIIGS.R) are awkward to work with and will change to match those found in the Tech Note on additional resource types.  This awkwardness doesn't really interfere with this Part of the resource tutorial, it's just generally annoying.
  103.  
  104. The MAKE files used for this tutorial assume that you have either the 
  105. "Programming Tools & Interfaces for APW" package or the "APW Tools &
  106. Interfaces" package.  The "Programming Tools..." package is no longer
  107. available (it was replaced by the newer "APW Tools..." package).  If you
  108. have the older package, then contact either APDA or Developer Tools
  109. Express (1-800-282-2732) and order the update from the old package to the
  110. new one (it's $25).  The part number for the update package is A0241LL/A.
  111. The new package ("APW Tools & Interfaces") is $50 and can also be ordered
  112. from either APDA or Developer Tools Express (both places use the same phone
  113. number:  1-800-282-2732).  If you don't have either of these packages, then 
  114. call APDA (or Developer Tools Express) and order part # A0240LL/A  to get
  115. the full package.  Both the update and the full package include new
  116. interfaces for APW C and APW Assembly - these interfaces have been
  117. extensively reviewed by DTS, engineering, etc to make them the best
  118. interfaces in a long time.
  119.  
  120. The MAKE files require Rez, LinkIIGS, and Duplicate (all three of which are
  121. in the packages I just mentioned).  If you're building these examples with
  122. ORCA/C, then you'll need to use the ORCA linker or run the CrunchIIGS script
  123. before you call LinkIIGS.  You'll also have to change the LinkIIGS command
  124. line (since ORCA/C doesn't use Start.root).  The ORCA/C MAKE file would be
  125. something (roughly) like:
  126.  
  127.      compile rtutor.cc keep=$
  128.      crunchIIGS rtutor
  129.      linkiigs rtutor.obj -lib 2/orcalib -lib 2/syslib -t exe -o rtutor.dfork
  130.      compile rtutor.rez keep=rtutor.rfork rez=(-t $5E)
  131.      set exit off
  132.      delete rtutor.s16
  133.      set exit on
  134.      duplicate -d rtutor.dfork rtutor.s16
  135.      duplicate -r rtutor.rfork rtutor.s16
  136.      filetype rtutor.s16 s16
  137.  
  138. If you use a linker other than LinkIIGS (or The Byte Work's new ZapLink) then
  139. you should convert your resulting applications to the more effecient OMF 2.0
  140. using the COMPACT tool.  While you're at it, make sure your COMPACT'd files
  141. take advantage of the IIGS's ExpressLoad facility for faster loading.  Use
  142. the EXPRESS tool to do the conversion of an OMF 2.0 file into one that takes
  143. advantage of ExpressLoad.  It's easier though to just use one of the two
  144. linkers I just named - they both produce OMF 2.0 and automatically "express" 
  145. their output.
  146.  
  147.  
  148.  
  149. Brought to you by,
  150.  
  151. Tim Swihart
  152. APW & MPW IIGS Product Manager
  153. Apple Computer, Inc.
  154. 20525 Mariani Ave, MS:  75-8X
  155. Cupertino, CA 95015
  156.  
  157. AppleLink:  Tim.Swihart
  158. GEnie:  Tim.Swihart
  159. America OnLine:  A2Pro Tim
  160.